package com.hex.liyue.storemodule.presenter;

import com.hex.liyue.commonmodule.manager.HttpManager;
import com.hex.liyue.commonmodule.manager.UserManager;
import com.hex.liyue.commonmodule.net.ResponseListener;
import com.hex.liyue.storemodule.bean.PayOrderDetailsResultBean;

/**
 * Created by WJ on 2016/6/29.
 */
public class StoreSureOrderPresenter {
    private IStoreSureOrderView iStoreSureOrderView;

    public StoreSureOrderPresenter(IStoreSureOrderView iStoreSureOrderView) {
        this.iStoreSureOrderView = iStoreSureOrderView;
    }

    /**
     * 提交订单
     */
    public void submitOrder(String gift_id, int gift_num) {
        iStoreSureOrderView.showLod("加载中...");
        HttpManager.getInstance().orders_create(UserManager.getUserId(), gift_id, gift_num, new ResponseListener<PayOrderDetailsResultBean>() {
            @Override
            public void onSuccess(PayOrderDetailsResultBean payOrderDetailsResultBean) {
                iStoreSureOrderView.closeLod();
                iStoreSureOrderView.closeCurrentActivity(payOrderDetailsResultBean);
            }

            @Override
            public void onFailure(String responseresult) {
                iStoreSureOrderView.closeLod();
                iStoreSureOrderView.showT(responseresult);
            }
        });
    }
}
